<template>
  <div class="login-page f-c a-c">
    <div class="login-form">
      <div class="title">注册</div>
      <el-form>
        <el-form-item label="">
          <el-input v-model="ruleForm.username" clearable placeholder="姓名" />
        </el-form-item>
        <el-form-item label="" style="margin-bottom: 0">
          <el-input v-model="ruleForm.number" clearable placeholder="学号" />
        </el-form-item>
        <el-form-item style="text-align: right">
          <el-link type="primary" @click="toRegiser">去登录</el-link>
        </el-form-item>
        <el-form-item>
          <el-button :disabled="isLogin" :loading="isLogin" type="primary" style="width: 100%" @click="login">{{ isLogin ? '注册中' : '注册' }}</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>
<script>
import { http } from '@/api'

export default {
  data() {
    return {
      radio: 'student',
      ruleForm: {
        username: 'student',
        number: '123456',
        type: 'student'
      },
      isLogin: false
    }
  },
  methods: {
    changeType(val) {
      if (val === 'admin') {
        this.$router.replace({
          path: '/login'
        })
      } else if (val === 'teacher') {
        this.$router.replace({
          path: '/login-teacher'
        })
      } else if (val === 'student') {
        this.$router.replace({
          path: '/login-student'
        })
      }
    },

    async login() {
      this.isLogin = true
      try {
        await http.student.updateStatus({
          student_name: this.ruleForm.username,
          number: this.ruleForm.number
        })
        this.$message.success('注册成功')
        this.toRegiser()
      } catch (e) {
        this.isLogin = false
      }
    },
    toRegiser() {
      this.$router.push({
        path: '/login-student'
      })
    }
  }
}
</script>
<style scoped lang="scss">
.login-page {
  background-image: url("~@/assets/login-bg.png");
  background-size: 100% 100%;
  background-repeat: no-repeat;
  min-width: 1440px;
  min-height: 892px;
  height: 100%;
  width: 100%;
  position: relative;
  .radio {
    position: absolute;
    top: 50px;
    right: 50px;
    z-index: 99;
  }
  .login-title {
    width: 976px;
    height: 133px;
    font-size: 57px;
    font-family: Microsoft YaHei;
    font-weight: bold;
    color: #FFFFFF;
    line-height: 77px;
    margin-top: 78px;
  }
  .login-form {
    margin-top: 178px;
    width: 413px;
    background: #FFFFFF;
    border-radius: 21px;
    padding: 40px;
    .title {
      color: #457EFF;
      font-size: 17px;
      line-height: 17px;
      position: relative;
      text-align: center;
      &::after {
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        bottom: -14px;
        width: 100px;
        background-color: #457EFF;
        height: 2px;
        display: inline-block;
        content: ' ';
      }
      margin-bottom: 43px;
    }

  }
}
</style>
